package com.dbgs.insurance.insuredperson.activity;

import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.widget.Button;
import android.widget.TextView;

import com.dbgs.insurance.insuredperson.R;
import com.dbgs.insurance.insuredperson.adapter.MyApplyListAdapter;
import com.hss.base.BaseActivty;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.jude.easyrecyclerview.decoration.DividerDecoration;
import com.lz.commonlibrary.utils.DensityUtils;
import com.meetme.android.multistateview.MultiStateView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/5/15.
 */

public class MyApplyActivity extends BaseActivty {

    @BindView(R.id.btn_tite_back)
    Button btnTiteBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_tite_right)
    TextView tvTiteRight;
    @BindView(R.id.easyrlv)
    com.jude.easyrecyclerview.EasyRecyclerView easyrlv;
    @BindView(R.id.msv_layout)
    MultiStateView msvLayout;

    MyApplyListAdapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_apply);
        ButterKnife.bind(this);
        initData();
        initView();
        initListener();
    }

    @Override
    public void initData() {
        super.initData();
    }

    @Override
    public void initView() {
        super.initView();
        tvTitle.setText(R.string.str_my_apply);

        if (adapter==null){
            adapter=new MyApplyListAdapter(this);
            adapter.setOnItemClickListener(onItemClickListener);
            adapter.setMore(R.layout.view_more,loadMoreListener);
            adapter.setNoMore(R.layout.view_nomore, noMoreListener);
            adapter.setError(R.layout.view_error, onErrorListener);
        }
        easyrlv.setAdapterWithProgress(adapter);
        easyrlv.setRefreshListener(refreshListener);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        easyrlv.setLayoutManager(layoutManager);
        DividerDecoration spaceDecoration = new DividerDecoration(getResources().getColor(R.color.transparent), DensityUtils.dp2px(getApplicationContext(), 15.0f));
        easyrlv.addItemDecoration(spaceDecoration);
        /*easyrlv.getSwipeToRefresh().setColorSchemeColors(getResources().getColor(R.color.google_blue),
                getResources().getColor(R.color.google_red),
                getResources().getColor(R.color.google_green),
                getResources().getColor(R.color.google_yellow));*/
    }

    @Override
    public void initListener() {
        super.initListener();

    }

    RecyclerArrayAdapter.OnItemClickListener onItemClickListener = new RecyclerArrayAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(int position) {

        }
    };
    SwipeRefreshLayout.OnRefreshListener refreshListener = new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
        }
    };
    RecyclerArrayAdapter.OnLoadMoreListener loadMoreListener = new RecyclerArrayAdapter.OnLoadMoreListener() {
        @Override
        public void onLoadMore() {
        }
    };
    RecyclerArrayAdapter.OnNoMoreListener noMoreListener = new RecyclerArrayAdapter.OnNoMoreListener() {
        @Override
        public void onNoMoreShow() {
            adapter.resumeMore();
        }

        @Override
        public void onNoMoreClick() {
            adapter.resumeMore();
        }
    };
    RecyclerArrayAdapter.OnErrorListener onErrorListener = new RecyclerArrayAdapter.OnErrorListener() {
        @Override
        public void onErrorShow() {
            adapter.resumeMore();
        }

        @Override
        public void onErrorClick() {
            adapter.resumeMore();
        }
    };
}
